home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 18
/
AMIGAplus Sonderheft 18 (1999)(ICP)(DE)[!].iso
/
PD
/
Anwendungen
/
FS1541-13
/
support.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-03
|
3KB
|
133 lines
/*
* FS1541 - support routines
*
* Copyright (C) 1996 - 1998 Michael Krause
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <exec/types.h>
#include <exec/execbase.h>
#include <dos/dosextens.h>
#include <dos/filehandler.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <proto/exec.h>
#include "support.h"
#include "main.h"
/*-------------------------------------------------------------------------*/
void ReturnPacket(struct DosPacket *packet, LONG res1, LONG res2)
{
struct MsgPort *mp = packet->dp_Port;
packet->dp_Port = ourport;
packet->dp_Res1 = res1;
packet->dp_Res2 = res2;
PutMsg(mp, packet->dp_Link);
}
struct DosPacket *GetPacket(struct MsgPort *port)
{
struct Message *msg;
if((msg = GetMsg(port)))
return((struct DosPacket *)msg->mn_Node.ln_Name);
else
return(NULL);
}
/*-------------------------------------------------------------------------*/
void copy64name(STRPTR dest, STRPTR src, UBYTE maxlen)
{
static const UBYTE conv[91]=
" !\"#$%&'()·+,-.\\0123456789|;<=>?"
"@abcdefghijklmnopqrstuvwxyz[£]^{"
"_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
UBYTE a;
while(((a=*src++) != 0xa0) && maxlen--)
if(a<32 || a>122)
*dest++ = '_';
else
*dest++ = conv[a-32];
*dest = '\0';
}
void asciito64(STRPTR dest, STRPTR src, UBYTE maxlen)
{
static const UBYTE conv[91]=
" !\"#$%&'()*+,-./0123456789:;<=>?"
"@abcdefghijklmnopqrstuvwxyz[/]^{"
"-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
UBYTE a;
while((a=*src++) && maxlen--)
if(a<32 || a>122)
*dest++ = ' ';
else
*dest++ = conv[a-32];
while(maxlen--)
*dest++ = 0xa0;
}
/*-------------------------------------------------------------------------*/
void SendEvent(BOOL insert)
{
struct IOStdReq *InputRequest;
struct MsgPort *InputPort;
struct InputEvent *ie;
if((InputPort = (struct MsgPort*)CreateMsgPort()))
{
if((InputRequest = (struct IOStdReq*)CreateIORequest(InputPort, sizeof(struct IOStdReq))))
{
if(!OpenDevice("input.device", 0, (struct IORequest*)InputRequest, 0))
{
if((ie = AllocVec(sizeof(struct InputEvent), MEMF_PUBLIC|MEMF_CLEAR)))
{
ie->ie_Class = insert ? IECLASS_DISKINSERTED : IECLASS_DISKREMOVED;
InputRequest->io_Command = IND_WRITEEVENT;
InputRequest->io_Data = ie;
InputRequest->io_Length = sizeof(struct InputEvent);
DoIO((struct IORequest*)InputRequest);
FreeVec(ie);
}
CloseDevice((struct IORequest*)InputRequest);
}
DeleteIORequest (InputRequest);
}
DeleteMsgPort (InputPort);
}
}
/*
Local Variables:
mode:c
c-basic-offset:8
End:
*/